#ifndef TCPSERVER_H
#define TCPSERVER_H

#include <QObject>
#include <QTcpSocket>
#include <QTcpServer>
#include <QHostAddress>
#include <QDebug>

#include "BasePort.h"

class TCPServer : public BasePort
{
    Q_OBJECT

public:
    Q_INVOKABLE  TCPServer(QObject *parent = 0);
    ~TCPServer();

    void setPortParam(PortStruct portParam);
    void open();
    void close();
    void write(PortStruct target, QByteArray data);

private:

    QTcpServer *tcpServer;
    QList<QTcpSocket*> m_tcpClientList;



private slots:
    void newConnectionSlot();
    void disconnectedSlot();
    void readyReadSlot();

};

#endif // TCPSERVER_H
